﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modulos/ModuloPrestamo/VistaControl/MasterPagePrestamo.master" AutoEventWireup="true" CodeFile="lugares.aspx.cs" Inherits="Modulos_ModuloPrestamo_VistaControl_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
Módulo de Préstamos - Administrador de Lugares
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h2>Administrador de Lugares</h2>
    <br />
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="LUG_ID" 
        DataSourceID="SqlDataSource1">
        <InsertItemTemplate>
            <table style="width: 100%" frame="box">
                <tr>
                    <td colspan="2">
                        Nuevo lugar</td>
                </tr>
                <tr>
                    <td>
                        Nombre:</td>
                    <td>
                        <asp:TextBox ID="NOMBRE_LUGTextBox" runat="server" 
                            Text='<%# Bind("NOMBRE_LUG") %>' />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="NOMBRE_LUGTextBox" Display="Dynamic" 
                            ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        Ubicación:</td>
                    <td>
                        <asp:TextBox ID="UBICACION_LUGTextBox" runat="server" 
                            Text='<%# Bind("UBICACION_LUG") %>' />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                            ControlToValidate="UBICACION_LUGTextBox" Display="Dynamic" 
                            ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
                            OnClientClick="javascript:if(!confirm('&iquest;Confirma insertar lugar?'))return false" 
                            CommandName="Insert" Text="Insertar" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
        <ItemTemplate>
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo lugar" />
            <br />
        </ItemTemplate>
        <EmptyDataTemplate>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Nuevo lugar" />
        </EmptyDataTemplate>
    </asp:FormView>
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="LUG_ID" 
                DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
                            OnClientClick="javascript:if(!confirm('¿Confirma actualizar lugar?'))return false" 
                                CommandName="Update" Text="Actualizar"></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                CommandName="Cancel" Text="Cancelar"></asp:LinkButton>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                CommandName="Edit" Text="Editar"></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
                            OnClientClick="javascript:if(!confirm('&iquest;Confirma eliminar lugar?'))return false" 
                                CommandName="Delete" Text="Eliminar"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="LUG_ID" HeaderText="Id" InsertVisible="False" 
                        ReadOnly="True" SortExpression="LUG_ID" />
                    <asp:TemplateField HeaderText="Nombre" SortExpression="NOMBRE_LUG">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NOMBRE_LUG") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                ControlToValidate="TextBox1" Display="Dynamic" 
                                ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("NOMBRE_LUG") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ubicación" SortExpression="UBICACION_LUG">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("UBICACION_LUG") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                ControlToValidate="TextBox2" Display="Dynamic" 
                                ErrorMessage="* campo obligatorio"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("UBICACION_LUG") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AppCeiiConnectionString %>"
        DeleteCommand="DELETE FROM [LUGAR_ENTREGA_DEVOLUCION] WHERE [LUG_ID] = @LUG_ID"
        InsertCommand="INSERT INTO [LUGAR_ENTREGA_DEVOLUCION] ([NOMBRE_LUG], [UBICACION_LUG]) VALUES (@NOMBRE_LUG, @UBICACION_LUG)"
        ProviderName="<%$ ConnectionStrings:AppCeiiConnectionString.ProviderName %>"
        SelectCommand="SELECT [LUG_ID], [NOMBRE_LUG], [UBICACION_LUG] FROM [LUGAR_ENTREGA_DEVOLUCION]"
        UpdateCommand="UPDATE [LUGAR_ENTREGA_DEVOLUCION] SET [NOMBRE_LUG] = @NOMBRE_LUG, [UBICACION_LUG] = @UBICACION_LUG WHERE [LUG_ID] = @LUG_ID">
        <DeleteParameters>
            <asp:Parameter Name="LUG_ID" Type="Decimal" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="NOMBRE_LUG" Type="String" />
            <asp:Parameter Name="UBICACION_LUG" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="NOMBRE_LUG" Type="String" />
            <asp:Parameter Name="UBICACION_LUG" Type="String" />
            <asp:Parameter Name="LUG_ID" Type="Decimal" />
        </UpdateParameters>
    </asp:SqlDataSource>
    
    </asp:Content>

